package p270jp.pxv.android.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import android.webkit.WebSettings;
import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
import p005a5.C0022b;
import p014ae.AbstractActivityC0154s2;
import p014ae.C0125n6;
import p046bf.PixivAppUserAgents;
import p047bg.C1124a;
import p079cl.C1189h;
import p079cl.PremiumPresenter;
import p090d0.C2518n;
import p134ei.AnalyticsAction;
import p134ei.PixivAnalytics;
import p134ei.PremiumAnalyticsSource;
import p165fo.Subscribe;
import p209hg.PremiumContract;
import p270jp.pxv.android.R;
import p270jp.pxv.android.commonObjects.model.ApplicationConfig;
import p270jp.pxv.android.event.StartRoutingActivityEvent;
import p307l9.EdgeTreatment;
import p314lg.ActivityPremiumBinding;
import p446qh.PremiumDomainService;
import p679zk.PremiumLpService;

/* renamed from: jp.pxv.android.activity.PremiumActivity */
/* loaded from: classes2.dex */
public class PremiumActivity extends AbstractActivityC0154s2 implements PremiumContract {

    /* renamed from: M */
    public static final /* synthetic */ int f18534M;

    /* renamed from: I */
    public C1189h f18535I;

    /* renamed from: J */
    public ActivityPremiumBinding f18536J;

    /* renamed from: K */
    public final PixivAppUserAgents f18537K = (PixivAppUserAgents) C2518n.m7641d(PixivAppUserAgents.class);

    /* renamed from: L */
    public ApplicationConfig f18538L;

    /* renamed from: V0 */
    public static Intent m4769V0(Context context, PremiumAnalyticsSource fVar) {
        EdgeTreatment.m3909i(context);
        EdgeTreatment.m3909i(fVar);
        Intent intent = new Intent(context, PremiumActivity.class);
        intent.putExtra("ANALYTICS_SOURCE", fVar);
        return intent;
    }

    /* renamed from: W0 */
    public void m4768W0() {
        m4767X0(getString(R.string.error_default_message));
    }

    /* renamed from: X0 */
    public void m4767X0(String str) {
        Toast.makeText(this, str, 1).show();
    }

    /* renamed from: Y0 */
    public void m4766Y0() {
        Toast.makeText(this, getString(R.string.billing_register_premium_succeed), 1).show();
        C1189h hVar = this.f18535I;
        PremiumAnalyticsSource fVar = hVar.f5554h;
        PixivAnalytics eVar = hVar.f5547a;
        switch (fVar.ordinal()) {
            case 0:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_SEARCH_RESULT_POPULAR);
                break;
            case 1:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_BADGE);
                break;
            case 2:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_BROWSING_HISTORY);
                break;
            case 3:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_SEARCH_RESULT_POPULAR_TOP);
                break;
            case 4:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_SEARCH_RESULT_POPULAR_BOTTOM);
                break;
            case 5:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_SEARCH_RESULT_POPULAR_TRIAL_BOTTOM);
                break;
            case 6:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_SEARCH_RESULT_NEW);
                break;
            case 7:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_SEARCH_RESULT_OLD);
                break;
            case 8:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_SEARCH_FILTER_BOOKMARK_COUNT);
                break;
            case 9:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_URL_SCHEME);
                break;
            case 10:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_MUTE_MANY_SETTING);
                break;
            case 11:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_MUTE_SETTING);
                break;
            case 12:
                eVar.m6528b(7, AnalyticsAction.PREMIUM_REGISTER_VIA_SETTING);
                break;
        }
        Intent intent = new Intent(this, RoutingActivity.class);
        intent.setFlags(268468224);
        startActivity(intent);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public void onBackPressed() {
        if (this.f18536J.f21384s.canGoBack()) {
            this.f18536J.f21384s.goBack();
        } else {
            this.f940i.m12030b();
        }
    }

    @Override // p270jp.pxv.android.activity.BaseActivity, androidx.fragment.app.FragmentActivity, androidx.activity.ComponentActivity, p248j2.ActivityC3902g, android.app.Activity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.f18536J = (ActivityPremiumBinding) DataBindingUtil.m11369d(this, R.layout.activity_premium);
        C1189h hVar = new C1189h(this, (PremiumDomainService) C2518n.m7640e(PremiumDomainService.class, null, new C0125n6(C0022b.m12183x(this), 1)), (PremiumLpService) C2518n.m7641d(PremiumLpService.class), this.f18757A, this.f18538L);
        this.f18535I = hVar;
        hVar.f5554h = (PremiumAnalyticsSource) getIntent().getSerializableExtra("ANALYTICS_SOURCE");
        ((PremiumActivity) hVar.f5550d).f18536J.f21384s.setWebViewClient(new PremiumPresenter(hVar));
        C1124a.m10197Q(this, this.f18536J.f21383r, R.string.premium);
        this.f18536J.f21384s.getSettings().setJavaScriptEnabled(true);
        WebSettings settings = this.f18536J.f21384s.getSettings();
        settings.setUserAgentString(this.f18536J.f21384s.getSettings().getUserAgentString() + " " + this.f18537K.f5005b);
        this.f18535I.m9724j();
    }

    @Override // p270jp.pxv.android.activity.BaseActivity, p116e.ActivityC2727f, androidx.fragment.app.FragmentActivity, android.app.Activity
    public void onDestroy() {
        this.f18535I.onDestroy();
        this.f18536J.f21384s.setWebViewClient(null);
        super.onDestroy();
    }

    @Subscribe
    public void onEvent(StartRoutingActivityEvent startRoutingActivityEvent) {
        Intent intent = new Intent(this, RoutingActivity.class);
        intent.setFlags(268468224);
        startActivity(intent);
    }

    @Override // androidx.activity.ComponentActivity, android.app.Activity
    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() != 16908332) {
            return false;
        }
        onBackPressed();
        return true;
    }
}
